/**
 * Copyright (C) Octlan Corporation. All rights reserved.
 * 
 * @author todzhang
 * @date 2010-2-24
 * @version $Id: PeopleListCursorAdapter.java 11 2010-03-03 06:44:06Z todzhang $
 */
package com.octlan.droid.mii.adapter;

import android.content.ContentUris;
import android.content.Context;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.provider.Contacts.People;
import android.view.View;
import android.widget.ImageView;
import android.widget.SimpleCursorAdapter;

import com.octlan.droid.mii.R;

public class PeopleListCursorAdapter extends SimpleCursorAdapter {

	public PeopleListCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to) {
		super(context, layout, c, from, to);
	}

	@Override
	public void bindView(View view, Context context, Cursor cursor) {
		super.bindView(view, context, cursor);

		ImageView photo = (ImageView) view.findViewById(R.id.ImageViewPeopleItemImage);
		int id = cursor.getColumnIndex(People._ID);
		Uri uri = ContentUris.withAppendedId(People.CONTENT_URI, cursor.getLong(id));
		Bitmap bitmap = People.loadContactPhoto(context, uri, R.drawable.mii_knot_32x32, null);
		photo.setImageBitmap(bitmap);
	}

}
